﻿// FilesIOLearning.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

//#include <iostream>
//#include <fstream>
//#include <string>
//#include <vector>

#include "FileIOHeaders.h"

int FilesIODemo()
{
    std::cout << "Hello World!\n";

	// 测试输出到文件
	try
	{
		std::ofstream outfile("./output.txt", std::ios::app);
		outfile << "Hello World!" << std::endl;
	}
	catch (const std::exception& err)
	{
		std::cout << err.what() << std::endl;
	}

	// 测试文件输入到内存变量
	std::string line;
	std::vector<std::string> text;
	try
	{
		std::ifstream inputfile("./input.txt", std::ios::app);
		while (std::getline(inputfile, line))
		{
			text.emplace_back(line);
			std::cout << line << std::endl;

		}
		std::cout << text.size() << std::endl;
	}
	catch (const std::exception& err)
	{
		std::cout << err.what() << std::endl;
	}

    return 0;
}


